<template>
	<view class="container">
		<uni-card :is-shadow="false" v-for="(item,index) in list" :key="index" :style="'padding-right: 0;'">
			<uni-row>
				<uni-col :span="10">
					<text class="uni-body">{{item.goodsName}}  {{item.payAmount}}元</text>
				</uni-col>
				<uni-col :span="14">
					<text class="uni-body" style="text-align: right;width: 100%;">{{item.createdDate}}</text>
				</uni-col>
			</uni-row>
		</uni-card>
		<uni-card :is-shadow="false" v-if="list.length == 0" >
			<uni-row>
				<uni-col :span="24" style="text-align: center;">
					暂无数据
				</uni-col>
			</uni-row>
		</uni-card>
		<view class="pages" v-if="total">
			<Pagination :totalPage="pages" :currentPage.sync="page" @pageNum="changePage"></Pagination>
		</view>
	</view>
</template>

<script>
	// 充值记录
	import Pagination from '@/components/pagination/pagination.vue';
	export default {
		components: {
			Pagination
		},
		data() {
			return {
				list: [],
				page: 1,
				pages: 0,
				total: 0
			};
		},
		onLoad(option) {

		},
		onShow() {
			//页面刷新执行
			this.getOrderList()
		},
		methods: {
			getOrderList() {
				let that = this;
				uni.getStorage({
					key: 'wx_openid',
					success: function(res) {
						that.openid = res.data;
						uni.request({
							url: that.baseUrl + '/my/rechargeList',
							method: 'POST',
							data: {
								pageSize: 10,
								pageNumber: that.page,
								openid: that.openid
							},
							success(res) {
								let type = res.data.type;
								if (type === 'success') {
									that.list = res.data.data.content;
									that.total = res.data.data.total;
									that.pages = res.data.data.totalPages;
								}
							}
						})
					}
				});

			},
			changePage(e) {
				this.page = e;
				this.getOrderList()
			}
		}
	}
</script>

<style>
	.uni-col-24{
		text-align: center;
	}
	.uni-col-14{
		text-align: end;
	}
</style>